S0="${BASH_SOURCE[0]}"
DIRNAME="$( dirname "$S0")"
DIR="$( cd "$DIRNAME" && pwd)"
echo $DIR/..

NODE="/usr/local/bin/node"
PYTHON="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3"

WORKSPACE=${WORKSPACE:=$(realpath "$DIR/..")}
echo WORKSPACE=$WORKSPACE
export WORKSPACE

JOB_NAME=${JOB_NAME:=MANUAL}
echo JOB_NAME=$JOB_NAME
export JOB_NAME

BUILD_NUMBER=${BUILD_NUMBER:=1}
echo BUILD_NUMBER=$BUILD_NUMBER
export BUILD_NUMBER

GIT_COMMIT=${GIT_COMMIT:="'00000000'"}
echo GIT_COMMIT=${GIT_COMMIT}
SHORT_GIT_COMMIT=$(echo $GIT_COMMIT | cut -c 1-8)
echo SHORT_GIT_COMMIT=${SHORT_GIT_COMMIT}

$NODE $WORKSPACE/ci/create_configconst.js $WORKSPACE/Game112Client/assets/scripts/ConfigConst.ts $BUILD_NUMBER $SHORT_GIT_COMMIT

$WORKSPACE/ci/build_web_mobile.sh

WEB_PATH=/opt/homebrew/var/www/game112/web-mobile/
rsync -avz --delete ${WORKSPACE}/Game112Client/build/web-mobile/ $WEB_PATH;

$PYTHON ${WORKSPACE}/ci/feishu_robot.py  ${JOB_NAME} ${BUILD_NUMBER} ${SHORT_GIT_COMMIT}